use std::error::Error;

use axum::{
    routing::{get, post},
    Router,
};
use axum_server::{
    router::{
        auth::{login_handler, logout_handler, password_modify_handler},
        global::{_404_handler, root_handler},
        user::{add_user, default_user},
    },
    util::net::CombinedIncoming,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let app = Router::new()
        .route("/", get(root_handler))
        .route("/auth/login", post(login_handler))
        .route("/auth/logout", post(logout_handler))
        .route("/auth/password", post(password_modify_handler))
        .route("/user", get(default_user).post(add_user))
        .fallback(_404_handler);
    let combined_incoming = CombinedIncoming::new(3000, 3000);
    hyper::Server::builder(combined_incoming)
        .serve(app.into_make_service())
        .await?;
    Ok(())
}
